$(function() {
	var scrollTimer,
		html = '',
		$menu = $(".macth-dropdown-menu");

	$menu.menuAim({
		activate: activateSubmenu,
		deactivate: deactivateSubmenu,
		exitMenu: function() {
			$(".macth_popover").hide();
			$(".macth_xvh3_a a.maintainHover").removeClass("maintainHover");
			$('.macth_xvitem.macth_itemhover').removeClass('macth_itemhover');
			$('.macth_xvitem s').show();
		}
	});

	function activateSubmenu(row) {
		var $row = $(row),
			submenuId = $row.data("submenuId"),
			$submenu = $("#" + submenuId),
			// height = $menu.outerHeight(),
			width = $menu.outerWidth();
		$submenu.css({
			display: "block",
			top: 0,
			left: width + 0
		});
		$row.addClass('macth_itemhover');
		$row.find("h3 a").addClass("maintainHover");
		$row.find("h3 s").hide();
	}

	function deactivateSubmenu(row) {
		var $row = $(row),
			submenuId = $row.data("submenuId"),
			$submenu = $("#" + submenuId);
		$submenu.hide();
		$row.removeClass('macth_itemhover');
		$row.find("h3 a").removeClass("maintainHover");
		$row.find("h3 s").show();
	}

	function showhide(dom,child){
		$(dom).hover(function() {
			$(this).addClass('active').find(child).show();
			$(this).siblings().find('.show').hide();
			$(this).siblings().removeClass('active');
		}, function() {
		});
	}
	//今日收益榜
	$(".scroll-top").hover(function() {
		clearInterval(scrollTimer);
	}, function() {
		scrollTimer = setInterval(function() {
			scrollNews($(".scroll-top"));
		}, 2000);
	}).trigger("mouseout");
	function scrollNews(obj) {
		var $self = obj.find("ul:first");
		var lineHeight = $self.find("li:first").height();
		$self.animate({
			"margin-top": -lineHeight + "px"
		}, 600, function() {
			$self.css({
				"margin-top": "0px"
			}).find("li:first").appendTo($self);
		})
	}
	
	//首页分类跳转
	$('.macth_xvitem h3').click(function(){
		$(this).css({'cursor':'pointer'});
		var class1=$(this).find('.macth_xvh3_a a').text();
		localStorage.removeItem('class2');		
		localStorage.removeItem('class3');
		localStorage.setItem('class1',class1);
		urlTo = "goods_itemize.html";
		indexUrl();
	})
	$('.macth_xvnav_li_alist').click(function(){
		var class2=$(this).text();
		localStorage.removeItem('class1');
		localStorage.removeItem('class3');
		localStorage.setItem('class2',class2);
		urlTo = "goods_itemize.html";
		indexUrl();
	})
	$('.macth_xvnav_li_ul li a').click(function(){
		var class3=$(this).text();
		localStorage.removeItem('class1');
		localStorage.removeItem('class2');
		localStorage.setItem('class3',class3);
		urlTo = "goods_itemize.html";
		indexUrl();
	})
});

function indexUrl(){
	var url = decodeURI(location.href);
	var STR = url.split('/');
	var str_ = STR[STR.length - 1];
	var qq = str_.substr(0, 10);
	var indexUrlSplitJoint = "../youba/public/";
	var indexUrlJump = "../";
	var jumpUrl = 0;
	if(qq == "index.html") {
		if(urlTo == "index.html") {
			jumpUrl = urlTo;
		} else {
			jumpUrl = indexUrlSplitJoint + urlTo;
		}
	} else {
		if(urlTo == "index.html") {
			jumpUrl = indexUrlJump + urlTo;
		} else {
			jumpUrl = urlTo;
		}
	}
	window.location.href = jumpUrl;
}
